PROGRAM quadratic
IMPLICIT NONE
REAL :: a,b,c
REAL :: d
REAL :: r1,r2
PRINT *,'Enter the coefficients of the quadratic equation - ax2 + bx + c'
PRINT *,'a:';	READ *,a
PRINT *,'b:';	READ *,b
PRINT *,'c:';	READ *,c

IF(a==0) THEN
	PRINT *,'Not a quadratic Equation'
	RETURN
END IF

d=b**2 - 4*a*c	!calculating the discriminant

IF(d==0) THEN
	r1 = -b/(2*a)
	PRINT *,'Single Root:',r1
ELSE IF(d>0) THEN
	r1 = (-b + SQRT(d)) / (2*a)
	r2 = (-b - SQRT(d)) / (2*a)
	PRINT *,'TWO ROOTS:',r1,r2
ELSE IF(d<0) THEN
	d=-d;
	PRINT *,'Two Complex Roots:'
	PRINT *,-b/(2*a),' + i',SQRT(d)/(2*a)
	PRINT *,-b/(2*a),' - i',SQRT(d)/(2*a)
END IF

END PROGRAM
